home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / hugearr.zip / HUGESET.C < prev    next >
C/C++ Source or Header  |  1992-04-02  |  943b  |  37 lines

  1.  
  2. #define NOCOMM
  3. #include <windows.h>
  4. #include <memory.h>
  5.  
  6. #include "hugearr.h"
  7.  
  8. /* Set a huge array element. */
  9. /* VBM: Declare Function VBHugeSet% Lib "hugearr.dll" Alias "VBHugeSet" (ByVal Index%, ByVal el&, buffer As Any) */
  10. int FAR PASCAL
  11. VBHugeSet(int hArray, long element, LPBYTE buffer)
  12.     {
  13.     HPBYTE    ptr;     /* pointer to array element */
  14.     PHUGEDESC pArray;  /* pointer to array descriptor */
  15.  
  16.     DecCheckHandle(hArray);
  17.  
  18.     /* point to proper descriptor */
  19.     pArray = (PHUGEDESC) LocalLock(hLocalMem) + hArray;
  20.  
  21.     CheckNotAllocYet(pArray);
  22.     CheckSubscript(pArray, element, element);
  23.  
  24.     /* calculate pointer to element */
  25.     ptr = (HPBYTE) GlobalLock(pArray -> handle);
  26.  
  27.     /* add offset of element */
  28.     ptr += HugeElementOffset(element, pArray->perseg, pArray->recsize);
  29.  
  30.     /* copy data */
  31.     _fmemcpy(ptr, buffer, pArray -> recsize);
  32.  
  33.     GlobalUnlock(pArray -> handle);
  34.     LocalUnlock(hLocalMem);
  35.     return HA_OK;
  36.     }
  37.